#include "LinkedListCycle.hpp"
#include "leetcode.h"

bool hasCycle( LinkedListNode* root )
{
    bool res = false;
    if ( root != std::nullptr_t() ) {
        LinkedListNode* f = root;
        LinkedListNode* s = root;

        while ( f != NULL && f->next != NULL ) {
            f = f->next->next;
            s = s->next;
            if ( f == s ) {
                res = true;
                break;
            }
        }
    }

    return res;
}